package com.shy.springframework.test.event;

import com.shy.springframework.beans.BeansException;
import com.shy.springframework.context.ApplicationContext;
import com.shy.springframework.context.ApplicationContextAware;
import com.shy.springframework.context.ApplicationEvent;

public class CustomService implements ApplicationContextAware {
    private ApplicationContext applicationContext;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public void publishEvent(){
        ApplicationEvent event = new CustomEvent(this, 123456789L, "注册成功");
        applicationContext.publishEvent(event);
    }
}
